﻿using System;
using DynamicProxy.AOP;
using DynamicProxy.Core;
using DynamicProxy.Core.AutoProxy;

namespace DynamicProxy.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //自动代理
            var t1 = ProxyBuilder<Interceptor>.BuildProxy(typeof(Dog));
            Dog dog = (Dog)Activator.CreateInstance(t1);
            dog.Talk("wang");

            //带缓存的自动代理
            Dog dog1 = new ProxyFactory<Interceptor>().CreateInstance<Dog>();
            dog1.Talk("wang with cache");
            Dog dog2 = new ProxyFactory<Interceptor>().CreateInstance<Dog>();
            dog2.Talk("wang with cache 2");

            //AOP
            Student student = new ProxyFactory<AOPInterceptor>().CreateInstance<Student>();
            student.Answer("A B C");

            Console.Read();
        }
    }
}
